package ChessEngine;

import boardData.*;

public class SimpleEvaluator extends AbstractEvalutor{
	
	@Override
	public int evaluate(Board b) {
		return countWhiteScore(b) - countBlackScore(b);
	}
	
	private int countBlackScore(Board b){
		
		int blackScore=0;
		for(int i=0; i<b.getArrayLength();i++){
			
			switch(b.getPiece(i))
			{
				case Board.BLACK_BISHOP	:	blackScore += AbstractEvalutor.BISHOP_SCORE;
				case Board.BLACK_KING	:	blackScore += AbstractEvalutor.KING_SCORE;
				case Board.BLACK_KNIGHT	:	blackScore += AbstractEvalutor.KNIGHT_SCORE;
				case Board.BLACK_PAWN	:  	blackScore += AbstractEvalutor.PAWN_SCORE;
				case Board.BLACK_QUEEN	: 	blackScore += AbstractEvalutor.QUEEN_SCORE;
				case Board.BLACK_ROOK	: 	blackScore += AbstractEvalutor.ROOK_SCORE;
			}
		}
		return blackScore;
	}
	
	private int countWhiteScore(Board b){
		
		int whiteScore=0;
		
		for(int i=0; i<b.getArrayLength();i++){
			
			switch(b.getPiece(i))
			{
				case Board.WHITE_BISHOP	:	whiteScore += AbstractEvalutor.BISHOP_SCORE;
				case Board.WHITE_KING	:	whiteScore += AbstractEvalutor.KING_SCORE;
				case Board.WHITE_KNIGHT	:	whiteScore += AbstractEvalutor.KNIGHT_SCORE;
				case Board.WHITE_PAWN	:  	whiteScore += AbstractEvalutor.PAWN_SCORE;
				case Board.WHITE_QUEEN	: 	whiteScore += AbstractEvalutor.QUEEN_SCORE;
				case Board.WHITE_ROOK	: 	whiteScore += AbstractEvalutor.ROOK_SCORE;
			}
		}
		return whiteScore;
	}
	
}
	
	